package com.seeyon.apps.ssoAndDoc.utils;

import com.seeyon.ctp.common.AppContext;
import com.seeyon.ctp.common.SystemEnvironment;
import com.seeyon.ctp.util.UUIDLong;

import java.io.File;
import java.util.Calendar;

public class FilePathUtil {
    private static String TEMP_FILE_URL = AppContext.getSystemProperty("ak.tempFileUrl");

    public FilePathUtil() {
    }

    public static String getFilePath() {
        Calendar now = Calendar.getInstance();
        String year = String.valueOf(now.get(1));
        String month = String.valueOf(now.get(2) + 1);
        String dayOfMonth = String.valueOf(now.get(5));
        String path = SystemEnvironment.getApplicationFolder();
        // 找到最后一个和倒数第二个斜杠的位置
        int lastIndex = path.lastIndexOf("\\");
        int secondLastIndex = path.lastIndexOf("\\", lastIndex - 1);
        int thirdLastIndex = path.lastIndexOf("\\", secondLastIndex-1);
// 截取字符串，去掉最后两个部分
        String newPath = path.substring(0, thirdLastIndex + 1); // +1 以包括倒数第二个斜杠
        Long uuid = UUIDLong.longUUID();
        String filePath = newPath+"base"+File.separator+"temporary" + File.separator + year + File.separator + month + File.separator + dayOfMonth+File.separator;
        File filePathOrder = new File(filePath);
        if (!filePathOrder.exists()) {
            filePathOrder.mkdirs();
        }

        return filePath;
    }
}
